package com.example.opengl.camera

import android.content.Context
import android.hardware.Camera
import android.opengl.GLSurfaceView
import android.os.Build
import android.util.AttributeSet
import android.view.Surface
import androidx.annotation.RequiresApi
import com.example.opengl.camera.filter.FilterType

/**
 * @author: Mr.You
 * @create: 2023-07-19 13:43
 * @description:
 **/
class MyGLSurfaceView(context: Context, attributeSet: AttributeSet? = null) : GLSurfaceView(context, attributeSet) {
    private var mRenderer: MyGLRender = MyGLRender(this)

    init {
        setEGLContextClientVersion(2)
        setRenderer(mRenderer)
        renderMode = RENDERMODE_WHEN_DIRTY
    }


    fun switchCamera() {
        mRenderer.changeCamera()
    }

    fun switchFilter(filterType: FilterType) {
        mRenderer.switchFilter(filterType)
    }

    fun setBeautyFilter(){
       queueEvent {
           mRenderer.setBeautyFilter()
       }
    }
    @RequiresApi(Build.VERSION_CODES.N)
    fun setRecordVideo(isRecord:Boolean){
        mRenderer.setRecordVideo(isRecord)
    }
}


